const tokens = {
	admin: {
		token: "admin-token"
	}
};

const users = {
	"admin-token": {
		name: "admin",
		avatar: "avatar1"
	}
};

module.exports = [
	{
		url: "/user/login",
		type: "post",
		response: config => {
			const { username } = config.body;
			const token = tokens[username];

			if (!token) {
				return {
					code: -1,
					message: "Account and password are incorrect."
				};
			}

			return {
				code: 200,
				data: token
			};
		}
	},

	{
		url: "/user/getInfo",
		type: "get",
		response: config => {
			const { token } = config.query;
			const info = users[token];

			if (!info) {
				return {
					code: -1,
					message: "Login failed, unable to get user details."
				};
			}

			return {
				code: 200,
				data: info
			};
		}
	},

	{
		url: "/user/logout",
		type: "post",
		response: () => {
			return {
				code: 200,
				data: "success"
			};
		}
	}
];
